import type { Context } from 'koa';
import { CreatePhotoDto } from '@/dtos/createPhoto.dto';
import { PhotoService } from '@/services/photo';

/**
 * 保存照片
*/
export const photoSaveController = async (ctx: Context) => {
  const creator = ctx.userId;
  const input = ctx.request.body;
  const params = await ctx.vailParams<CreatePhotoDto>(CreatePhotoDto, input);
  const result = await PhotoService.createNewPhoto({ ...params, creator });
  ctx.sendSuccess({ id: result._id });
}